package com.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Vector;

public class CargaVenta {
	
	private String A=null;
	private String B=null;
	private String C=null;
	private String D=null;
	private String E=null;
	private String F=null;
	private String G=null;
	private String H=null;
	private String I=null;
    
	private Vector vecCargaVenta=new Vector();

	public String getA() {
		return A;
	}

	public void setA(String a) {
		A = a;
	}

	public String getB() {
		return B;
	}

	public void setB(String b) {
		B = b;
	}

	public String getC() {
		return C;
	}

	public void setC(String c) {
		C = c;
	}

	public String getD() {
		return D;
	}

	public void setD(String d) {
		D = d;
	}

	public String getE() {
		return E;
	}

	public void setE(String e) {
		E = e;
	}

	public String getF() {
		return F;
	}

	public void setF(String f) {
		F = f;
	}

	public String getG() {
		return G;
	}

	public void setG(String g) {
		G = g;
	}

	public String getH() {
		return H;
	}

	public void setH(String h) {
		H = h;
	}

	public String getI() {
		return I;
	}

	public void setI(String i) {
		I = i;
	}

	public Vector getVecCargaVenta() {
		return vecCargaVenta;
	}

	public void setVecCargaVenta(Vector vecCargaVenta) {
		this.vecCargaVenta = vecCargaVenta;
	}
	
	public static double CargarVentas(Connection conn, int ano, int periodo, String codCorredor) {
	     
		PreparedStatement pstmt = null; 
		ResultSet rset=null; boolean found=false;    
		try {   
  
			pstmt=conn.prepareStatement("Select * from CARGAVTA");  
			rset=pstmt.executeQuery();       
			if(rset!=null)  {   
				while(rset.next())   {
				found=true;
				
				System.out.println("---------"+ano+periodo+" VENTA"+rset.getString("A")+ "" +rset.getString("B") + "" +rset.getString("C")  );  
			    }      
			} 
			
			if (found ==false)  {   
				System.out.println("No Information Found");  }  
			} catch (SQLException e) {     
				System.out.println("DB2 Database connection Failed");     
			    e.printStackTrace();        
			}
			 
		return 0.00;
	}
	
	public static void main(String[] argv) {
		
		try {   
			Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");     
		} catch (ClassNotFoundException e) {      
			System.out.println("Please include Classpath  Where your DB2 Driver is located");      
			e.printStackTrace();      
			return;      
		}  
		System.out.println("DB2 driver is loaded successfully");  
		 
		Connection conn = null; 
		PreparedStatement pstmt = null; 
		ResultSet rset=null; boolean found=false;    
		try {   
			conn = DriverManager.getConnection("jdbc:db2:sample");         
			if (conn != null)  {    
				System.out.println("DB2 Database Connected");  }        
			else  {           
				System.out.println("Db2 connection Failed ");        }  
		

			CargaVenta obj=new CargaVenta();
			double crecimientoActual=obj.CargarVentas(conn, 2011, 9, "1303877");
		
		
	    } catch (SQLException e) {     
		      System.out.println("DB2 Database connection Failed");     
	          e.printStackTrace();        
	    }
	   
		
	}
	
}
	
	
 
